<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="box"></div>
    
    <script>
        // vue2 底层原理
        var obj = {}
        Object.defineProperty(obj,'myname',{
            set(value){ // 属性被赋值时调用 
                console.log('set')
                box.innerHTML=value
            },
            get(){ // 属性被访问时调用
                console.log('get')
            }
        })
    </script>
</body>
</html>